package com.augurit.wf.app.notice.convert;

import java.util.ArrayList;
import java.util.List;

import com.augurit.wf.app.notice.web.form.NoticeForm;
import com.augurit.wf.common.entity.Notice;

/**
 * 公告转换类
 *
 */
public class NoticeConverter {
	//entity转换为form
	public static NoticeForm convertToForm(Notice entity){
		NoticeForm form = null ;
		if(entity != null){
			form = new NoticeForm();
			form.setId(entity.getId());
			form.setTitle(entity.getTitle());
			form.setContent(entity.getContent());
			form.setPublisher(entity.getPublisher());
			form.setPublishTime(entity.getPublishTime());
			form.setImportance(entity.getImportance());
			form.setIsPublish(entity.getIsPublish());
		}
		return form;
	}
	
	//entity列表转换为form列表
	public static List<NoticeForm> convertToFormList(List<Notice> entities){
		List<NoticeForm> result = null;
		if(entities != null && entities.size() > 0){
			result = new ArrayList<NoticeForm>();
			for(Notice entity:entities){
				result.add(convertToForm(entity));
			}
		}
		return result;
	}
	
	//form转换为entity
	public static void convertToEntity(NoticeForm form, Notice entity){
		if(form != null && entity != null){
			entity.setId(form.getId());
			entity.setTitle(form.getTitle());
			entity.setPublisher(form.getPublisher());
			entity.setPublishTime(form.getPublishTime());
			entity.setContent(form.getContent());
			entity.setImportance(form.getImportance());
			entity.setIsPublish(form.getIsPublish());
		}
	}
}
